<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
		<title></title>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link href="../../css/app.css" rel="stylesheet" />
		<link href="../../fonts/iconfont.css" rel="stylesheet" />
		<link href="../../css/mui.indexedlist.css" rel="stylesheet" />
		<style>
			html,
			body {
				height: 100%;
				overflow: hidden;
			}
			#immersed{
				height: 0;
				width: 100%;
				background-color: #1653fc;
				position: fixed;
				top: 0;
				left: 0;
				z-index: 999;
			}
			.mui-table-view-divider{clear: both;}
			.mui-table-view-cell{float:left;width: 30%;font-size: 16px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
			.mui-table-view-cell:after{height: 0;}
			.mui-ios .mui-indexed-list-group, .mui-ios .mui-indexed-list-item, .mui-ios .mui-indexed-list-empty-alert{padding-right: 0;}
			.mui-indexed-list-bar{background-color: #fff;border-left: 1px solid #ccc;}
			.mui-table-view-divider:before{background-color: #fff;}
			.mui-table-view-divider:after{background-color: #fff;}
			.mui-indexed-list-group, .mui-indexed-list-item{padding-right:0;}
			.mui-icon-search:before { font-family:"iconfont" !important;content: "\e65b"; font-size: 16px;}
			.mui-search:before{ font-family:"iconfont" !important;content: "\e609"; font-size: 18px;}
			.mui-search .mui-placeholder .mui-icon{color: #999;}
		</style>
	</head>

	<body>
		<div class="mui-bar mui-bar-nav" id="header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"><span></span></a>
			<h1 class="mui-title">部门选择</h1>
		</div>
		<div class="mui-content" id="content">
			<div id='list' class="mui-indexed-list">
				<div class="mui-indexed-list-search mui-input-row mui-search">
					<input type="search" class="mui-input-clear mui-indexed-list-search-input" placeholder="部门搜索">
				</div>
				<div class="mui-indexed-list-bar">
					<a>A</a>
					<a>B</a>
					<a>C</a>
					<a>D</a>
					<a>E</a>
					<a>F</a>
					<a>G</a>
					<a>H</a>
					<a>I</a>
					<a>J</a>
					<a>K</a>
					<a>L</a>
					<a>M</a>
					<a>N</a>
					<a>O</a>
					<a>P</a>
					<a>Q</a>
					<a>R</a>
					<a>S</a>
					<a>T</a>
					<a>U</a>
					<a>V</a>
					<a>W</a>
					<a>X</a>
					<a>Y</a>
					<a>Z</a>
				</div>
				<div class="mui-indexed-list-alert"></div>
				<div class="mui-indexed-list-inner">
					<div class="mui-indexed-list-empty-alert">没有数据</div>
					<ul class="mui-table-view" id="bumenList">
						<!--<li data-group="A" class="mui-table-view-divider mui-indexed-list-group">A</li>
						<li data-value="AJJ" data-tags="AnJianJu" class="mui-table-view-cell mui-indexed-list-item">省安监局</li>
						<li data-value="GAJ" data-tags="GongAnJu" class="mui-table-view-cell mui-indexed-list-item">公安局</li>
						<li data-group="B" class="mui-table-view-divider mui-indexed-list-group">B</li>
						<li data-value="MBJ" data-tags="MiBaoJu" class="mui-table-view-cell mui-indexed-list-item">省保密局</li>
						<li data-value="BB" data-tags="BianBan" class="mui-table-view-cell mui-indexed-list-item">省编办</li>
						<li data-group="C" class="mui-table-view-divider mui-indexed-list-group">C</li>
						<li data-value="CHJ" data-tags="CeHuiJu" class="mui-table-view-cell mui-indexed-list-item">省测绘局</li>
						<li data-value="CGQ" data-tags="BianBan" class="mui-table-view-cell mui-indexed-list-item">省编办</li>
						<li data-value="CGQ" data-tags="ChangChunLongJiaGuoJi" class="mui-table-view-cell mui-indexed-list-item">省财政厅</li>
						<li data-group="D" class="mui-table-view-divider mui-indexed-list-group">D</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省地税局</li>
						<li data-value="CGQ" data-tags="ChangChunLongJiaGuoJi" class="mui-table-view-cell mui-indexed-list-item">省档案局</li>
						<li data-value="CGQ" data-tags="ChangChunLongJiaGuoJi" class="mui-table-view-cell mui-indexed-list-item">省地震局</li>
						<li data-group="F" class="mui-table-view-divider mui-indexed-list-group">F</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省发改委</li>
						<li data-group="G" class="mui-table-view-divider mui-indexed-list-group">G</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省公安厅</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省国土厅</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省工商局</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省国防科工办</li>
						<li data-group="H" class="mui-table-view-divider mui-indexed-list-group">H</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省公安厅</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省国土厅</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省工商局</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省国防科工办</li>
						<li data-group="I" class="mui-table-view-divider mui-indexed-list-group">I</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省公安厅</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省国土厅</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省工商局</li>
						<li data-value="NBS" data-tags="ChangBaiShan" class="mui-table-view-cell mui-indexed-list-item">省国防科工办</li>-->
					</ul>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var my_immersed = function(immersed) {
				document.getElementById("header").style.paddingTop = immersed + 'px';
				document.getElementById("header").style.height = (immersed + 44) + 'px';
				document.getElementById("content").style.paddingTop = (immersed + 44) + 'px';
			}
		</script>
		<script src="../../js/immersed.js"></script>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/mui.indexedlist.js"></script>
		<script src="../../js/common.js"></script>
		<script src="../../js/app.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			//初始化初始化indexedList
			var beforeViewId,districtId;
			function initIndexedList(){
				var header = document.querySelector('div.mui-bar');
				var list = document.getElementById('list');
				//calc hieght
				list.style.height = (document.body.offsetHeight - header.offsetHeight) + 'px';
				//create
				window.indexedList = new mui.IndexedList(list);
			}
			mui.plusReady(function(){
				beforeViewId = plus.webview.currentWebview().beforeViewId;
				districtId = plus.webview.currentWebview().districtId;
				mui.back = function(){
					plus.webview.currentWebview().close('zoom-fade-in',300)
				}
				//获取当前区划
				// 根据区划id获取机构列表
				utils.ajax('appHttpService/queryOrgan.do',function(data){
					//关闭进度条
	                closeWaitingAndShowView();
					var data = JSON.parse(data);
					if (data.state == '1') {
						var orgs = JSON.parse(data.orgMap);
						var bumenList = document.getElementById("bumenList");
						for(var str in orgs) {
							var groupEle = createElm('li',{"data-group":str,"class":"mui-table-view-divider mui-indexed-list-group"},str);
							bumenList.appendChild(groupEle);
							var organs = orgs[str];
							for (var i=0;i<organs.length;i++) {
								var organ = organs[i];
								var itemEle = createElm('li',{"data-value":organ.simplePinYin,"data-tags":organ.fullPinYin,"class":"mui-table-view-cell mui-indexed-list-item","id":organ.id},organ.name);
								bumenList.appendChild(itemEle);
							}
						}
						//构建数据后，重新初始化indexedList
						initIndexedList();
						
						//给部门绑定事件
						mui("#bumenList").on('tap','.mui-indexed-list-item',function(){
							var id = this.getAttribute("id");
							var name = this.innerText;
							localStorage.setItem("orgName",name);
							if(beforeViewId){
								var workIndex = plus.webview.getWebviewById(beforeViewId);
								mui.fire(workIndex,"updateOrgan",{"id":id,"name":name});
							}
							//办事指南列表页面
							var bsznListView = plus.webview.getWebviewById("../work/bszn_list.html-sub");
							mui.fire(bsznListView,"updateOrgan",{"id":id,"name":name});
							mui.back();
						});
					} else {
						mui.toast(data.msg);
					}
				},'districtId='+districtId);
			});
		</script>
	</body>

</html>